﻿using System;
using System.Collections.Generic;
using System.Data;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsParameter
    {
        public static List<Entity.Parameter> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.Parameter.Select(db);
            }
            
        }

        public static DataTable GetAll()
        {
            using (var db = Sys.NewDb())
            {
                return db.ExecuteDataTable("SELECT * FROM ReportParam");
            }
            
        }


        public static void Insert(Entity.Parameter capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<Entity.Parameter>(capital, EnumSaveMode.Requery);
            }
            
        }

        public static void Update(Entity.Parameter capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<Entity.Parameter>(capital);
            }
            
        }

        public static Entity.Parameter SelectByPk(Int32 paraId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<Entity.Parameter>(string.Format("ParamerterId={0}", paraId));
            }
            
        }

        public static int DeleteByPk(Int32 paraId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<Entity.Parameter>(string.Format("ParamerterId={0}", paraId));
            }
            
        }
    }
}
